From: Andrew Cooper Date: Thu, 13 Mar 2014 13:38:37 +0000 (+0100) Subject: console: Traditional console timestamps including milliseconds X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5453^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=006528196b81002a9c22e3e5c01a78542981ef60;p=xen.git console: Traditional console timestamps including milliseconds Suggested-by: Don Slutz Signed-off-by: Andrew Cooper Acked-by: Ian Campbell Acked-by: Keir Fraser --- diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index 80a0a5598e..689ffe69d5 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -275,7 +275,7 @@ cleared. This allows a single port to be shared by two subsystems makes sense on its own. ### console\_timestamps -> `= none | date | boot` +> `= none | date | datems | boot` > Default: `none` @@ -284,6 +284,8 @@ Specify which timestamp format Xen should use for each console line. * `none`: No timestamps * `date`: Date and time information * `[YYYY-MM-DD HH:MM:SS]` +* `datems`: Date and time, with milliseconds + * `[YYYY-MM-DD HH:MM:SS.mmm]` * `boot`: Seconds and microseconds since boot * `[SSSSSS.uuuuuu]` diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c index 81e3e2889c..22e94bbb0f 100644 --- a/xen/arch/arm/time.c +++ b/xen/arch/arm/time.c @@ -282,7 +282,7 @@ void domain_set_time_offset(struct domain *d, int32_t time_offset_seconds) /* XXX update guest visible wallclock time */ } -struct tm wallclock_time(void) +struct tm wallclock_time(uint64_t *ns) { return (struct tm) { 0 }; } diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 4f4de22f7e..f904af2011 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1646,15 +1646,19 @@ int dom0_pit_access(struct ioreq *ioreq) return 0; } -struct tm wallclock_time(void) +struct tm wallclock_time(uint64_t *ns) { - uint64_t seconds; + uint64_t seconds, nsec; if ( !wc_sec ) return (struct tm) { 0 }; seconds = NOW() + SECONDS(wc_sec) + wc_nsec; - do_div(seconds, 1000000000); + nsec = do_div(seconds, 1000000000); + + if ( ns ) + *ns = nsec; + return gmtime(seconds); } diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 9c032bf3e2..7fa9b789ce 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -53,6 +53,7 @@ enum con_timestamp_mode { TSM_NONE, /* No timestamps */ TSM_DATE, /* [YYYY-MM-DD HH:MM:SS] */ + TSM_DATE_MS, /* [YYYY-MM-DD HH:MM:SS.mmm] */ TSM_BOOT /* [SSSSSS.uuuuuu] */ }; @@ -560,6 +561,8 @@ static void __init parse_console_timestamps(char *s) if ( *s == '\0' || /* Compat for old booleanparam() */ !strcmp(s, "date") ) opt_con_timestamp_mode = TSM_DATE; + else if ( !strcmp(s, "datems") ) + opt_con_timestamp_mode = TSM_DATE_MS; else if ( !strcmp(s, "boot") ) opt_con_timestamp_mode = TSM_BOOT; else if ( !strcmp(s, "none") ) @@ -577,7 +580,8 @@ static void printk_start_of_line(const char *prefix) switch ( opt_con_timestamp_mode ) { case TSM_DATE: - tm = wallclock_time(); + case TSM_DATE_MS: + tm = wallclock_time(&nsec); if ( tm.tm_mday == 0 ) return; @@ -586,6 +590,11 @@ static void printk_start_of_line(const char *prefix) snprintf(tstr, sizeof(tstr), "[%04u-%02u-%02u %02u:%02u:%02u] ", 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + else + snprintf(tstr, sizeof(tstr), + "[%04u-%02u-%02u %02u:%02u:%02u.%03"PRIu64"] ", + 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, nsec / 1000000); break; case TSM_BOOT: diff --git a/xen/include/xen/time.h b/xen/include/xen/time.h index 3eb5b63b5c..27034544c9 100644 --- a/xen/include/xen/time.h +++ b/xen/include/xen/time.h @@ -48,7 +48,7 @@ struct tm { int tm_isdst; /* daylight saving time */ }; struct tm gmtime(unsigned long t); -struct tm wallclock_time(void); +struct tm wallclock_time(uint64_t *ns); #define SYSTEM_TIME_HZ 1000000000ULL #define NOW() ((s_time_t)get_s_time())